//
//  LogoProxy.m
//  weiGuan
//
//  Created by Zhou Ya on 2/17/14.
//
//

#import "LogoProxy.h"
#import "Constants.h"
#import "LogoDA.h"

@implementation LogoProxy

- (NSDictionary *)getSessionInfo{
    NSURL *url = [NSURL URLWithString:URL_CNSServlet];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    
    NSDictionary *parameters = [[NSDictionary alloc] initWithObjectsAndKeys:M001,pMethodId, nil];
    [request setPostValue:[parameters JSONString] forKey:pDataStr];

    [request startSynchronous];
    NSString *jsonResult = [request responseString];
    
    NSLog(@"%@", jsonResult);
    
    NSData *jsonData = [jsonResult dataUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *resultDic = [jsonData objectFromJSONData];
    
    //insert to local db
    LogoDA *logoDA = [LogoDA new];
    [logoDA insertSessionInfo:resultDic[m001_currentSessionId] userId:resultDic[m001_currentUserId]];
    
    return resultDic;
}

@end
